import store from "@/store";
import utils from '@/common/utils/utils.js'
import request from "@/common/utils/request";
import { nanoid } from "nanoid";
import { message, Modal, notification } from "ant-design-vue";
import { createVNode, h } from "vue";


// 默认org_id
export const defaultOrg_id = 1

export const envOrg_id = 2

// 视频文件类型
export const accept = {
    videoAccept: ".mp4,.mov,.3gp",
    imageAccept: ".jpg,.jpeg,.png,.gif",
    audioAccept: ".mp3,.m4a,.aac,.wav"
}

// 二创去重
export const getRemovalList = () => {
    return [
        {
          type: "icon-jiequmian",
          title: "智能截取",
          isselect: true,
          desc: "能够有效降低成片中的重复度，尤其在素材较长时效果更为显著",
          isre: true,
          id: "1"
        },
           {
          type: "icon-scale-fill",
          title: "智能缩放",
          isselect: true,
          desc: "自动对素材画面进行缩放裁剪，有效减少成片中的重复度，提升视觉多样性。",
          isre: false,
          id: "2"
        },
           {
          type: "icon-jingxiang",
          title: "智能镜像",
          isselect: false,
          desc: "自动将素材画面进行左右镜像处理，有效减少成片中的重复度，增加画面变化感。",
          isre: false,
          id: "3"
        },
        {
          type: "icon-shipinchouzhen",
          title: "智能抽帧",
          isselect: false,
          desc: "系统智能将成片抽帧（删除帧），一定程度上降低成片的重复度",
          isre: false,
          id: "4"
        },
         {
          type: "icon-mengban",
          title: "透明蒙版",
          isselect: false,
          desc: "自动抽取同一层素材的部分区域作为透明蒙版覆盖，一定程度上降低成片的重复度",
          isre: false,
          id: "5"
        },
        {
          type: "icon-mengban",
          title: "随机变速",
          isselect: false,
          desc: "轻微变速，不影响整体效果",
          isre: false,
          id: "6"
        }
      ]
} 

// 获取 是否是单独数字人的路由配置
export const getOnly_digital_human = () => {
  return new Promise(async (resolve, reject) => {
    try {
      let only_digital_human = store?.state?.user?.aiConfig?.only_digital_human
      if(typeof only_digital_human != 'boolean') {
        const config =  await store.dispatch("getAiConfig");
        only_digital_human = config?.only_digital_human ?? false
      }
      resolve(only_digital_human??false)
    } catch (error) {
      resolve(false)
    }
  })
}

// 处理 后台登录
export const setConfige = () => {
  // 获取当前URL参数
  const urlParams = new URLSearchParams(window.location.search);
  
  // 处理token
  const token = urlParams.get("token");
  if (token) {
    utils.setUserToken(token);
    urlParams.delete('token'); // 从参数列表删除
  }
  // 处理team_id
  const team_id = urlParams.get("team_id");
  if(team_id) {
    store.dispatch("SetTeamId", team_id);
    urlParams.delete('team_id'); // 擦掉
  }
  // 创建干净的新URL（保留其他参数）
  // const cleanSearch = urlParams.toString();
  // const newUrl = window.location.pathname + 
  //               (cleanSearch ? `?${cleanSearch}` : "") + 
  //               window.location.hash;
  // // 替换URL（不刷新页面）
  // history.replaceState({}, document.title, newUrl);
}

// 判断路由是否要隐藏的逻辑
export const hiddenRouterFn = () => {
  return new Promise( (resolve, reject) => {

     store.dispatch("GetConfigInfo").then(async () => {
       store.dispatch("Getwork_ai_config").then(async (aiConfig) => {

        // 开发模式 或未登录 或未正确获取配置参数 不做判断
         if (utils.isEnv() || !utils.isLogin() || !Object.keys(aiConfig)) {
          resolve()
          return;
        }
        
        const shotstack_driver = aiConfig.shotstack_driver || ""
        // 判断是否有阿里云的权限, 没有阿里的权限 则将一键成片路由删除
        if (shotstack_driver != "alionline") {
          const find = routes
            .find((item) => item.name == "workShotstack")
            .children.find((item) => item.name == "CreationCenter");
          if (!!find) {
            const index = find.children.findIndex(
              (item) => item.name == "OneClickClip"
            );
            index != -1 && find.children.splice(index, 1);
          }
        }
  
        // http://localhost:4022/workShotstack/digitalHuman/AIdigitalHuman
        // 声音克隆 路由
        // http://localhost:4022/workShotstack/home
        // const hasVolc = false;
        // const hasDigital = false;
        
        // 判断是否有数字人和声音克隆的权限
        const hasVolc = aiConfig.hasVolc || false;
        const hasDigital = aiConfig?.hasDigital || false;
        const workShotstack = routes.find((item) => item.name == "workShotstack");
        const digitalHumanIndex = workShotstack?.children.findIndex(
          (item) => item.name == "digitalHuman"
        );
        
        // 所有有关数字人的权限都没有, 直接删除数字人分身的路由
        if (!hasVolc && !hasDigital) {
          if (typeof digitalHumanIndex == "number" && digitalHumanIndex != -1) {
            workShotstack.children.splice(digitalHumanIndex, 1);
          }
        } else if (!hasDigital) {
          if (typeof digitalHumanIndex == "number" && digitalHumanIndex != -1) {
            // 数字人形象路由
            const AIdigitalHumanIndex = workShotstack.children[
              digitalHumanIndex
            ].children.findIndex((item) => item.name == "AIdigitalHuman");
            AIdigitalHumanIndex != -1 &&
              workShotstack.children[digitalHumanIndex].children.splice(
                AIdigitalHumanIndex,
                1
              );
  
            // 数字人视频生成路由
            const AIdigitalHumanCreatVideoIndex = workShotstack.children[
              digitalHumanIndex
            ].children[AIdigitalHumanIndex].findIndex(
              (item) => item.name == "AIdigitalHumanCreatVideo"
            );
            AIdigitalHumanCreatVideoIndex != -1 &&
              workShotstack.children[digitalHumanIndex].children.splice(
                AIdigitalHumanCreatVideoIndex,
                1
              );
          }
        } else if (!hasVolc) {
          // 声音克隆路由
          const SoundCloningIndex = workShotstack.children[
            digitalHumanIndex
          ].children.findIndex((item) => item.name == "SoundCloning");
          SoundCloningIndex != -1 &&
            workShotstack.children[digitalHumanIndex].children.splice(
              SoundCloningIndex,
              1
            );
         }
         resolve()
      });
    })
  })

}

// 用户套餐 - 页面权限
 export const routerConfig = {
  // 视频混剪
  'sphj': ['MixedCutIntroduction', 'mixedCutCreat', 'MixedCutPreview'],
  // 脚本剪辑
  'jbjj': ['ScriptingTool', 'ScriptSquare'],
  // 文字转语音
  'wzzyy': ['TextToSpeech'],
  // ai创作
  'aicz': ['AISceneCenter'],
  // 视频智能拆分
  'spzncf': ['AddVideoIntelligentSplit', 'videoIntelligentSplitList', 'VideoSplit'],
  // 提取视频文字
   'tqspwz': ['addVideoToText', 'VideoToTextList'],

  //  // 视频提取
  //  'sptq': ['VideoExtractionIndex', 'VideoExtractionList'],
  //  // 视频提取音频
  //  'sptqyp': ['VideoExtractAudioIndex', 'VideoExtractAudioList'],
  //  // 视频去除音频
  //  'spqcyp': ['VideoRemoveAudioIndex', 'VideoRemoveAudioList'],
  //  // 视频裁剪
  //  'sqcj': ['VideoCroppingIndex', 'VideoCroppingList'],
  //  // 视频擦除字幕
  //  'sqzmcc': ['VideoRemoveSubtitlesIndex', 'VideoRemoveSubtitlesList'],
  //  // 视频擦除标志
  // 'sqccbz': ['VideoRemoveSignIndex', 'VideoRemoveSignList'],
}

// key 对应的页面 name
export const routerKeyInPage = {
  'wzzyy': 'TextToSpeech',
  'aicz': 'SceneCenter',
  'spzncf': 'AddVideoIntelligentSplit',
  'tqspwz': 'AddVideoToText',
  'sptq': 'VideoExtractionIndex',
  'sptqyp': 'VideoExtractAudioIndex',
  'spqcyp': 'VideoRemoveAudioIndex',
  'sqcj': 'VideoCroppingIndex',
  'mbgc': 'TemplateList',
  'sqzmcc': 'VideoRemoveSubtitlesIndex',
  'sqccbz': 'VideoRemoveSignIndex',
}

// 用户角色 - 功能页面权限
export const roleConfig = {
  // 视频混剪: 混剪创建, 混剪预览
  'MixedCutIntroduction': ['mixedCutCreat', 'MixedCutPreview'],
  // 图文剪辑: 图文剪辑创建, 图文剪辑预览
  'GraphicTextCutList': ['GraphicTextCut', 'GraphicTextCutPreview'],
  // 脚本剪辑: 脚本剪辑创建 脚本编辑
  'ScriptingTool': ['ScriptSquare', 'templateScriptSquare'],
  // 视频拆分: 拆分记录, 拆分功能页面
  'AddVideoIntelligentSplit': ['VideoIntelligentSplitList', 'VideoSplit'],
  // 视频提取: 提取记录页面
  'VideoExtractionIndex': ['VideoExtractionList'],
  // 提取视频文字


  // 文案仿写: 仿写历史记录, 仿写详情
  'TextImitation': ['TextImitationList', 'CopywritingFissionDetail'],
  // 创作工具: 场景
  'AISceneCenter': ['SceneCreation'],
  // 智能发布: 发布详情, 发布功能页
  'ReleaseList': ['ReleaseDetail', 'AutoRelease'],
  // 爆店码: 爆店码创建详情页
  'BurstShop': ['BurstShopDetail'],
  // 抖转微: 创建外链, 创建外链卡片
  'TiktoktoWechat': ['Creatingdrainagetool', 'CreatCart'],
  // 账户管理: 推广链接, 点数充值
  'BusinessRecord': ['InviteNewUsers', 'VoucherCenter'],
  // 矩阵管理: 分组管理
  'IpManage':['AccountGroupList'],

  // 视频提取
   'sptq': ['VideoExtractionIndex', 'VideoExtractionList'],
   // 视频提取音频
   'sptqyp': ['VideoExtractAudioIndex', 'VideoExtractAudioList'],
   // 视频去除音频
   'spqcyp': ['VideoRemoveAudioIndex', 'VideoRemoveAudioList'],
   // 视频裁剪
   'sqcj': ['VideoCroppingIndex', 'VideoCroppingList'],
   // 视频擦除字幕
   'sqzmcc': ['VideoRemoveSubtitlesIndex', 'VideoRemoveSubtitlesList'],
    // 视频擦除标志
    'sqccbz': ['VideoRemoveSignIndex', 'VideoRemoveSignList'],
    // 视频翻译
   'spfy': ['VideoTranslateIndex', 'VideoTranslateList'],
  // 视频生成字幕
    'spsczm': ['VideoGenerateSubtitlesIndex', 'VideoGenerateSubtitlesList'],
  
}

// 创意工具权限判断 - 有其中任何一项的key 则可以访问 创意工具菜单
export const creativityTools = {
  // 文字转语音 wzzyy
  'TextToSpeech': [],
  'wzzyy':[],
// AI创作 aicz
  'SceneCenter': [],
  'aicz': [],
// 视频智能拆分 spzncf
  'AddVideoIntelligentSplit': ['VideoIntelligentSplitList'],
  'spzncf': ['VideoIntelligentSplitList'],
// 提取视频文字 tqspwz
  'AddVideoToText': ['VideoToTextList'],
  'tqspwz':['VideoToTextList'],
// 视频提取 sptq
  'VideoExtractionIndex': ['VideoExtractionList'],
  'sptq':['VideoExtractionList'],
// 视频提取音频 sptqyp
  'VideoExtractAudioIndex': ['VideoExtractAudioList'],
  'sptqyp':['VideoExtractAudioList'],
// 视频去除音频 spqcyp
  'VideoRemoveAudioIndex': ['VideoRemoveAudioList'],
  'spqcyp':['VideoRemoveAudioList'],
// 视频裁剪 sqcj
  'VideoCroppingIndex': ['VideoCroppingList'],
 'sqcj':['VideoCroppingList'],
// 视频擦除字幕 sqzmcc
  'VideoRemoveSubtitlesIndex': ['VideoRemoveSubtitlesList'],
  'sqzmcc':['VideoRemoveSubtitlesList'],
// 视频擦除标志 sqccbz
  'VideoRemoveSignIndex': ['VideoRemoveSignList'],
  'sqccbz':['VideoRemoveSignList']
  }

// 路由白名单
export const whiteList = [
  'NoticeList', 'Download', 'userinfo', 'UseAgreement','PrivacyAgreement', 'NoticeList', 'TextPreview'
]

// 路由权限判断配置
export const PermissionConfigs = {
  // 定制数字人参数逻辑
  only_digital_human: false,
  haveArr: [],
  // 用户拥有的路由列表
  menus: [],
  // 是否是主创权限 1 -是 0 -否
  power: 0,
  // 用户套餐权限列表
  roleUser:undefined,
  // 是否是完全 没有权限的账号
  notRedirect: false,
  clearData() {
    console.log('执行了PermissionConfigs清空', this);
    this.only_digital_human = false
    this.haveArr = []
    this.menus = []
    this.power = 0
    this.roleUser = undefined
    this.notRedirect = false

    // 清空缓存的 仓库confige信息
    store.commit('SET_USER_TEAM_DETAIL', null)
  }
}

/**
* 智能数字格式化器
* @param {number} num - 要格式化的数字
* @returns {string} 萌萌哒格式化结果
*/
export const meowNumberFormatter = (num) => {
  // 修正后的单位阈值配置（按正确量级排序）
  const units = [
    { value: 1e12, symbol: '万亿', threshold: 1e12 }, // 万亿级
    { value: 1e8, symbol: '亿', threshold: 1e8 },     // 亿级
    { value: 1e4, symbol: '万', threshold: 1e4 }     // 万级
  ];

  if (num < 10000) return num.toString();

  // 现在会正确匹配单位的真实量级了！
  const matchedUnit = units.find(unit => num >= unit.threshold);
  
  // 添加小数点保护逻辑
  const value = num / matchedUnit.value;
  const formatted = value % 1 === 0 
    ? value.toFixed(0) 
    : value.toFixed(1).replace(/\.0$/, '');

  return `${formatted}${matchedUnit.symbol}`;
}

export function meowDateDiff(startDate, endDate) {
  // 给日期戴上猫耳铃铛（处理时区）
  const parseDate = str => {
    const [y, m, d] = str.split('-').map(Number);
    return new Date(y, m-1, d, 12, 0, 0); // 中午12点避免夏令时问题
  };

  // 时间转换器
  const start = parseDate(startDate);
  const end = parseDate(endDate);
  const diff = Math.abs(end - start);
  
  // 天数（86400000 = 24*60*60*1000）
  return Math.round(diff / 86400000); 
}

// 获取系统信息
export const detectOS = () => {
  const userAgent = navigator.userAgent;
  
  // 优先检测移动设备
  if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(userAgent)) {
    return 'Mobile Device';
  }

  // PC系统检测
  if (userAgent.indexOf('Win') !== -1) return 'Windows';
  if (userAgent.indexOf('Mac') !== -1) return 'MacOS';
  if (userAgent.indexOf('Linux') !== -1) return 'Linux';
  if (userAgent.indexOf('X11') !== -1) return 'UNIX';
  
  return 'Unknown OS';
}

// 语音转文字, 积分消耗提示词
export const getText_to_speechConfig = async () => {
  const res = await request.get(
      "/work_ai",
      "/user/shotstack/text_to_speech/config/get"
    );
  console.log(res, "获取配置");
  // 业务名称
  const name = res?.numberInfo?.name
  // 积分别名
  const pointName = res?.pointInfo?.name 
  // 业务消耗单位
  const unit = res?.numberInfo?.unit
  // 积分消耗单位
  const pointUnit = res?.pointInfo?.unit
  // 积分消耗数量
  const pointNumber = res?.pointInfo?.consumes
  const tips = `${name}消耗${pointNumber}${pointUnit}${pointName}/${unit}`
  return tips
}

// 获取音色基础配置
export const getVoiceConfige = async () => {
  return new Promise(async (resolve, reject) => {   
    Promise.all([
      store.dispatch("videoMixCut/getDefaultVoiceData"),
      store.dispatch("videoMixCut/getRequestVoiceData"),
    ]).then(() => {
      // 默认的音色数据
      const defaultVoiceData = store.state.videoMixCut.defaultVoiceData;
      // 默认音色配置
      const voice_config = store.state.videoMixCut.voice_config;
      
      // 推荐音色配置
      const ather_voice_config = store.state.videoMixCut.volcengine_config
      //  old_config.value = store.state.videoMixCut.voice_config;
    console.log(voice_config,defaultVoiceData,'voice_configvoice_config');
      let data
      if (defaultVoiceData.voice_type == 2) {
        data = {
          emotion_intensity: '', //情感程度
          speed: ather_voice_config.speed.default, // 语速
          volume: '', // 音量
          emotion_category: "neutral", // 预期情感类型
          ...defaultVoiceData
        };
      } else {
        data = {
          emotion_intensity: voice_config.intensity.default, //情感程度
          speed: voice_config.speed.default, // 语速
          volume: voice_config.volume.default, // 音量
          emotion_category: "neutral", // 预期情感类型
          ...defaultVoiceData
        };
      }

      // 初始值
      resolve({
        data,
        voice_config
      })
    }).catch(() => {
      reject()
    })
  })
 
}

/**
 *
 * @param {需要分组的数组} array
 * @param {每一组的分组数量} chunkSize
 * @returns 返回分组之后的数组
 */
export const chunkArray = (array, chunkSize) => {
  const result = [];
  for (let i = 0; i < array.length; i += chunkSize) {
    const chunk = array.slice(i, i + chunkSize);
    result.push(chunk);
  }
  return result;
};

// 接收一个数组, 进行批量获取音频
export const getAudioList = (arr) => {
  return new Promise(async (resolve, reject) => {

    const resArr = []

    const promiseArr = [];
    arr.forEach((item) => {
      promiseArr.push(() =>
        getItemTextToAudio(item, {
          mexid_all: false,
        }, resArr)
      );
    });

    const chuckList = chunkArray(promiseArr, 5);

    for (let i = 0; i < chuckList.length; i++) {
      await Promise.all(chuckList[i].map((ele) => ele()))
        .then(() => {
          console.log("完成了一组视频组的音频获取", resArr);
          
        })
        .catch((err) => {
          console.log("视频组音频获取失败", resArr);
          reject(err);
          throw new Error(err);
        });
    }

    resolve(resArr)
  })
 
}

// 获取单项的音频
export const getItemTextToAudio = (getAudioItem, params, resArr) => {
  return new Promise(async (resolve, rej) => {
    const { mexid_all=false } = params;

      // 循环中 处理每一组数据, 将subtitle 扁平数组 处理成 嵌套数组 每一个嵌套数组处理成一个请求项

      // 获取音频的异步方法
      const promiseItem = (data) => {
        const { requestData } = data;
        return new Promise(async (resolve, reject) => {
          // 获取此项 tts的音频选项
          // console.log(requestData, "每一组的每一个接受到的参数");
          try {
            const res = await request.post(
              "/work_ai",
              "/user/shotstack/textToVoice/many",
              { ...requestData, mexid_all }
            );
            // console.log(res.result, "many调用的结果");
            if (res?.code && res.code != 1000) {
              throw new Error(res);
            }
            // 创建一个函数用于延迟
            const delay = (ms) =>
              new Promise((timeresolve) => setTimeout(timeresolve, ms));

            // 找到对应的数据, 存放数据
            const setVoice = (arr) => {
              console.log(arr, '转语音结果???');
              resArr.push(...arr)
            };

            // 使用新的获取音频接口
            const getItemVoice = async () => {
              const itemVoice = await request.get(
                "/work_ai",
                `/user/shotstack/textToVoice/many/result/${requestData.unique}`
              );
              // console.log("单项的轮询结果123", itemVoice);
              if (itemVoice?.code && itemVoice?.code != 1000) {
                throw new Error(itemVoice);
              }
              if (itemVoice?.result?.status) {
                if (itemVoice.result.status == "loading") {
                  await delay(2000);
                  await getItemVoice();
                  return;
                }
                if (itemVoice.result.status == "error") {
                  return message.error("音频获取失败!");
                }
              } else {
                // console.log("itemVoice?.result 有数据啦", itemVoice?.result);
                setVoice(itemVoice?.result);
              }
            };
            await getItemVoice();
          } catch (error) {
            message.destroy();
            setTimeout(() => {
              message.error("字幕语音转换失败,请重试!");
            })
            reject();
            rej();
          }
          resolve();
        });
    };
    
      const requestData = {
        ...getAudioItem?.voiceConfige,
        text: getAudioItem?.text,
        unique: nanoid(),
        // ssml_content
      };
    
    await promiseItem({
      requestData
    })

    resolve()
    
  });
};

// 滚动条滚动到最底部
export const scrollToBottom = (id) => {
    const el = document.querySelector(id);
    el.scrollTo({
        top: el.scrollHeight,
        behavior: "smooth",
    });
};

// 算力不足, 提示是否去充值
export const whetherToUp = (params) => {
  const { title = "提示", content = "", ok = null, res={} } = params;
  return new Promise((resolve, reject) => {
    // 如果消耗点数为 0 直接成功
    console.log(res,'提示接受到res');
    if (res?.pointInfo?.consumes <= 0) {
      resolve('ok')
      return
    }

     Modal.confirm({
      okText: "去充值",
      cancelText: "取消",
      title,
      zIndex:9999,
      content: h("div", {}, [content]),
      onOk() {
        console.log("ok");
        resolve("ok");
      },
      onCancel() {
        reject("cancel");
      },
    });
  });
}

// 获取用户套餐信息
const getVersionInfo = async(data = {}) => {
 const res =  await request.get(
    "work_ai",
    "/user/shotstack/version/info"
  )
  return res
};
 
// 获取用户套餐类型,. 试用 过期 或者是正式版(套餐未过期)
export const packageType = () => {
  return new Promise(async (resolve, reject) => {
    try {
    const versionInfo = await getVersionInfo()
    console.log(versionInfo, '用户套餐信息');
    // 判断给定日期是否已过期
    function isExpired(dueDateString) {
      // 转换给定日期字符串为 Date 对象
      const expirationDate = new Date(dueDateString);
      
      // 设置到期日期为该天的 23:59:59
      expirationDate.setHours(23, 59, 59, 999);

      // 获取当前时间
      const now = new Date();

      // 如果当前时间大于到期日期，说明已经到期
      return now > expirationDate;
    }

    // 示例用法
    const dueDate = versionInfo.result?.expire_time;
    const result = isExpired(dueDate);
      console.log(result, '是否过期');
      if (versionInfo.result?.free_send == 1) {
        resolve({
          type: '试用用户',
        })
        return
      } else if (result || !dueDate) {
        // 套餐过期用户
        resolve({
          type: '套餐过期',
        })
        return
      }
        resolve({
          type: '正式客户',
        })
    } catch (error) {
      console.log(error, '获取用户套餐信息失败');
      reject({
        error,
        type:'error'
      })
    }
  })
}

  /**
   * @description: 获取省市区县等信息
   * @param {Number} level 当前等级
   * @param {Array} optionList 返回的列表
   * @param {Object} extra 其他信息： id 请求id ; leafLevel: 叶子节点等级
   */
export const getAreaOptions = (level, optionList, extra = { id: "", leafLevel: 5 }) => {
    return new Promise((resolve) => {
      let requestUrl = "";
      let requestParams = {};
      switch (level) {
        case 1:
          // 省
          requestUrl = "/district/province_list";
          break;
        case 2:
          // 市
          requestUrl = "/district/city_list";
          requestParams = { province_id: extra.id };
          break;
        case 3:
          // 区
          requestUrl = "/district/district_list";
          requestParams = { city_id: extra.id };
          break;
        case 4:
          // 街道/乡
          requestUrl = "/district/street_list";
          requestParams = { district_id: extra.id };
          break;
        case 5:
          // 社区/村
          requestUrl = "/district/community_list";
          requestParams = { street_id: extra.id };
          break;
        default:
          requestUrl = "";
          break;
      }
      if (requestUrl) {
        let leafLevel = extra.leafLevel || 5;
        request.get("/public", requestUrl, requestParams).then((res) => {
          if (res.list) {
            optionList = res.list.map((item) => ({
              value: item.area_code,
              label: item.name,
              level,
              isLeaf: level == leafLevel,
            }));
            resolve(optionList);
          }
        });
      }
    });
}
  
  /**
   * @description: 为公共组件提供的请求方法
   */
export const commonRequest = (emitObj) => {
    const { params, success, fail } = emitObj;
    const { method, server, url, extra = {} } = params;
    request[method](server, url, extra)
      .then((res) => success(res))
      .catch((err) => fail(err));
}
  
// 混剪 特效选择文案 展示文案
export const getEffectsTips = (item) => {
  console.log(item, 'tipsItem');
  const {subtitle_effects = null} = item

  if(!subtitle_effects) return ''

  const AaiMotionInEffectTips = subtitle_effects.AaiMotionInEffect.isRandom
    ? '入场特效:随机; ' : `入场特效:${subtitle_effects.AaiMotionInEffect.value.length}个; `

      const AaiMotionOutEffectTips = subtitle_effects.AaiMotionOutEffect.isRandom
    ? '出场特效:随机; ' : `出场特效:${subtitle_effects.AaiMotionOutEffect.value.length}个; `

      const AaiMotionLoopEffectTips = subtitle_effects.AaiMotionLoopEffect.isRandom
    ? '循环特效:随机' : `循环特效:${subtitle_effects.AaiMotionLoopEffect.value.length}个`
    
  const tips = `(${AaiMotionInEffectTips + AaiMotionOutEffectTips + AaiMotionLoopEffectTips})`

  return tips
}

